package com.itheima.mapper;

import com.itheima.pojo.CheckGroup;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface CheckGroupMapper {

    /**
     * 添加检查组
     * @param checkGroup
     */
    void addCheckGroup(CheckGroup checkGroup);
    void addCheckGroupAndCheckItem(String code, List<Integer> checkitemIds);

    /**
     * 删除检查组
     * @param id
     */
    @Delete("delete from t_checkgroup_checkitem where checkgroup_id = #{id}")
    void deleteCheckItemAndCheckGroup(Integer id);
    @Delete("delete from t_checkgroup where id = #{id}")
    void deleteById(Integer id);

    /**
     * 根据套餐id查询关联的检查项id
     * @param setmealId
     * @return
     */
    @Select("select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{setmealId}")
    List<Integer> findCheckGroupIdsBySetmealId(Integer setmealId);

    /**
     * 分页查询
     * @param currentPage
     * @param pageSize
     * @param queryString
     * @return
     */
    List<CheckGroup> pageList(Integer currentPage, Integer pageSize, String queryString);


    /**
     * 查询所有
     * @return
     */
    @Select("select * from t_checkgroup")
    List<CheckGroup> findAll();

    /**
     * 根据id查询检查组
     * @param id
     * @return
     */
    @Select("select * from t_checkgroup where id = #{id}")
    CheckGroup findById(Integer id);
}
